<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>lwIP: Memory pools</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">lwIP
   &#160;<span id="projectnumber">2.1.2</span>
   </div>
   <div id="projectbrief">Lightweight IP stack</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__mempool.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a>  </div>
  <div class="headertitle">
<div class="title">Memory pools<div class="ingroups"><a class="el" href="group__infrastructure.html">Infrastructure</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ga92fc8c29d0e2654f2a2ecc43b2b7fb13"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mempool.html#ga92fc8c29d0e2654f2a2ecc43b2b7fb13">LWIP_MEMPOOL_PROTOTYPE</a>(name)&#160;&#160;&#160;extern const struct <a class="el" href="structmemp__desc.html">memp_desc</a> memp_ ## name</td></tr>
<tr class="separator:ga92fc8c29d0e2654f2a2ecc43b2b7fb13"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5b1fb3ce7942432d87cc948b1c5ed6cb"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mempool.html#ga5b1fb3ce7942432d87cc948b1c5ed6cb">LWIP_MEMPOOL_DECLARE</a>(name,  num,  size,  desc)</td></tr>
<tr class="separator:ga5b1fb3ce7942432d87cc948b1c5ed6cb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga60b51c06d276f525b35d8b7abd4dcb41"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mempool.html#ga60b51c06d276f525b35d8b7abd4dcb41">LWIP_MEMPOOL_INIT</a>(name)&#160;&#160;&#160;<a class="el" href="memp__priv_8h.html#a6416303426d05526bed33f241fa6ecd7">memp_init_pool</a>(&amp;memp_ ## name)</td></tr>
<tr class="separator:ga60b51c06d276f525b35d8b7abd4dcb41"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5e2498f6c17746c1fe7153de5f7f275a"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mempool.html#ga5e2498f6c17746c1fe7153de5f7f275a">LWIP_MEMPOOL_ALLOC</a>(name)&#160;&#160;&#160;<a class="el" href="memp__priv_8h.html#a348c83ee972f1edf7296a1cdf1d75f22">memp_malloc_pool</a>(&amp;memp_ ## name)</td></tr>
<tr class="separator:ga5e2498f6c17746c1fe7153de5f7f275a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa43d114dd702fbd8f1db18474ea93a04"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mempool.html#gaa43d114dd702fbd8f1db18474ea93a04">LWIP_MEMPOOL_FREE</a>(name,  x)&#160;&#160;&#160;<a class="el" href="memp__priv_8h.html#a62f8c3c907743e34eee3cdac7fa1eaa5">memp_free_pool</a>(&amp;memp_ ## name, (x))</td></tr>
<tr class="separator:gaa43d114dd702fbd8f1db18474ea93a04"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Custom memory pools </p>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a id="ga5e2498f6c17746c1fe7153de5f7f275a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5e2498f6c17746c1fe7153de5f7f275a">&#9670;&nbsp;</a></span>LWIP_MEMPOOL_ALLOC</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define LWIP_MEMPOOL_ALLOC</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">name</td><td>)</td>
          <td>&#160;&#160;&#160;<a class="el" href="memp__priv_8h.html#a348c83ee972f1edf7296a1cdf1d75f22">memp_malloc_pool</a>(&amp;memp_ ## name)</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Allocate from a private memory pool </p>

</div>
</div>
<a id="ga5b1fb3ce7942432d87cc948b1c5ed6cb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5b1fb3ce7942432d87cc948b1c5ed6cb">&#9670;&nbsp;</a></span>LWIP_MEMPOOL_DECLARE</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define LWIP_MEMPOOL_DECLARE</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">name, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">num, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">size, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">desc&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line"><a class="code" href="group__compiler__abstraction.html#ga651bb349041669fe717b19f127ef16c0">LWIP_DECLARE_MEMORY_ALIGNED</a>(memp_memory_ ## name ## _base, ((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))); \</div><div class="line">    \</div><div class="line">  LWIP_MEMPOOL_DECLARE_STATS_INSTANCE(memp_stats_ ## name) \</div><div class="line">    \</div><div class="line">  static <span class="keyword">struct </span>memp *memp_tab_ ## name; \</div><div class="line">    \</div><div class="line">  const <span class="keyword">struct </span><a class="code" href="structmemp__desc.html">memp_desc</a> memp_ ## name = { \</div><div class="line">    DECLARE_LWIP_MEMPOOL_DESC(desc) \</div><div class="line">    LWIP_MEMPOOL_DECLARE_STATS_REFERENCE(memp_stats_ ## name) \</div><div class="line">    LWIP_MEM_ALIGN_SIZE(<a class="code" href="structmemp__desc.html#a1688d2bdd5a7b77700e1fa627f025ba3">size</a>), \</div><div class="line">    (<a class="code" href="structmemp__desc.html#a2c32db78e565b8812ca0e20fe929a8a7">num</a>), \</div><div class="line">    memp_memory_ ## name ## _base, \</div><div class="line">    &amp;memp_tab_ ## name \</div><div class="line">  };</div><div class="ttc" id="structmemp__desc_html_a1688d2bdd5a7b77700e1fa627f025ba3"><div class="ttname"><a href="structmemp__desc.html#a1688d2bdd5a7b77700e1fa627f025ba3">memp_desc::size</a></div><div class="ttdeci">u16_t size</div><div class="ttdef"><b>Definition:</b> memp_priv.h:119</div></div>
<div class="ttc" id="structmemp__desc_html_a2c32db78e565b8812ca0e20fe929a8a7"><div class="ttname"><a href="structmemp__desc.html#a2c32db78e565b8812ca0e20fe929a8a7">memp_desc::num</a></div><div class="ttdeci">u16_t num</div><div class="ttdef"><b>Definition:</b> memp_priv.h:123</div></div>
<div class="ttc" id="group__compiler__abstraction_html_ga651bb349041669fe717b19f127ef16c0"><div class="ttname"><a href="group__compiler__abstraction.html#ga651bb349041669fe717b19f127ef16c0">LWIP_DECLARE_MEMORY_ALIGNED</a></div><div class="ttdeci">#define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size)</div><div class="ttdef"><b>Definition:</b> arch.h:271</div></div>
<div class="ttc" id="structmemp__desc_html"><div class="ttname"><a href="structmemp__desc.html">memp_desc</a></div><div class="ttdef"><b>Definition:</b> memp_priv.h:108</div></div>
</div><!-- fragment --><p>Declare a private memory pool Private mempools example: .h: only when pool is used in multiple .c files: <a class="el" href="group__mempool.html#ga92fc8c29d0e2654f2a2ecc43b2b7fb13">LWIP_MEMPOOL_PROTOTYPE(my_private_pool)</a>; .c:</p><ul>
<li>in global variables section: LWIP_MEMPOOL_DECLARE(my_private_pool, 10, sizeof(foo), "Some description")</li>
<li>call ONCE before using pool (e.g. in some init() function): <a class="el" href="group__mempool.html#ga60b51c06d276f525b35d8b7abd4dcb41">LWIP_MEMPOOL_INIT(my_private_pool)</a>;</li>
<li>allocate: void* my_new_mem = <a class="el" href="group__mempool.html#ga5e2498f6c17746c1fe7153de5f7f275a">LWIP_MEMPOOL_ALLOC(my_private_pool)</a>;</li>
<li>free: <a class="el" href="group__mempool.html#gaa43d114dd702fbd8f1db18474ea93a04">LWIP_MEMPOOL_FREE(my_private_pool, my_new_mem)</a>;</li>
</ul>
<p>To relocate a pool, declare it as extern in cc.h. Example for GCC: extern u8_t __attribute__((section(".onchip_mem"))) memp_memory_my_private_pool_base[]; </p>

</div>
</div>
<a id="gaa43d114dd702fbd8f1db18474ea93a04"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa43d114dd702fbd8f1db18474ea93a04">&#9670;&nbsp;</a></span>LWIP_MEMPOOL_FREE</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define LWIP_MEMPOOL_FREE</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">name, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">x&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td>&#160;&#160;&#160;<a class="el" href="memp__priv_8h.html#a62f8c3c907743e34eee3cdac7fa1eaa5">memp_free_pool</a>(&amp;memp_ ## name, (x))</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Free element from a private memory pool </p>

</div>
</div>
<a id="ga60b51c06d276f525b35d8b7abd4dcb41"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga60b51c06d276f525b35d8b7abd4dcb41">&#9670;&nbsp;</a></span>LWIP_MEMPOOL_INIT</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define LWIP_MEMPOOL_INIT</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">name</td><td>)</td>
          <td>&#160;&#160;&#160;<a class="el" href="memp__priv_8h.html#a6416303426d05526bed33f241fa6ecd7">memp_init_pool</a>(&amp;memp_ ## name)</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Initialize a private memory pool </p>

</div>
</div>
<a id="ga92fc8c29d0e2654f2a2ecc43b2b7fb13"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga92fc8c29d0e2654f2a2ecc43b2b7fb13">&#9670;&nbsp;</a></span>LWIP_MEMPOOL_PROTOTYPE</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define LWIP_MEMPOOL_PROTOTYPE</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">name</td><td>)</td>
          <td>&#160;&#160;&#160;extern const struct <a class="el" href="structmemp__desc.html">memp_desc</a> memp_ ## name</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Declare prototype for private memory pool if it is used in multiple files </p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
